Skip to content

Conversation

soumik12345
Copy link
Contributor

@soumik12345 soumik12345 commented Apr 15, 2025

Description

Create DeepSORTTracker as an implementation of the SORT (Simple Online and Realtime Tracking With a Deep Association Metric).

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Example Usage

import numpy as np
import supervision as sv
from ultralytics import YOLO

from trackers import DeepSORTTracker, DeepSORTFeatureExtractor

model = YOLO("yolov8l", task="detect", verbose=False)
feature_extractor = DeepSORTFeatureExtractor.from_timm(
    model_name="mobilenetv4_conv_small.e1200_r224_in1k", pretrained=True
)
tracker = DeepSORTTracker(feature_extractor=feature_extractor)
box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()


def callback(frame: np.ndarray, _: int):
    results = model(frame, verbose=False, imgsz=1280)[0]
    detections = sv.Detections.from_ultralytics(results)
    detections = tracker.update(detections, frame)

    labels = [
        f"#{tracker_id} {results.names[class_id]} {confidence:.2f}"
        for tracker_id, class_id, confidence in zip(
            detections.tracker_id, detections.class_id, detections.confidence
        )
    ]
    annotated_image = frame.copy()
    annotated_image = box_annotator.annotate(annotated_image, detections)
    annotated_image = label_annotator.annotate(annotated_image, detections, labels)

    return annotated_image


sv.process_video(
    source_path="data/traffic_video.mp4",
    target_path="data/out.mp4",
    callback=callback,
    max_frames=100,
)

Docs

  • Docs updated

@CLAassistant
Copy link

CLAassistant commented Apr 15, 2025

CLA assistant check
All committers have signed the CLA.

@soumik12345 soumik12345 changed the title add: DeepSORTTracker feat(trackers): Implement DeepSORTTracker Apr 15, 2025
@SkalskiP SkalskiP merged commit 03cbd3e into main Apr 15, 2025
17 checks passed
@soumik12345 soumik12345 deleted the feat/deepsort-tracker branch April 15, 2025 14:26
soumik12345 pushed a commit that referenced this pull request Apr 17, 2025
update: 🚀 enhance .gitignore, add pre-commit configuration, and refine pyproject.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants